home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s5.arc / SENDMODE.MOD < prev    next >
Text File  |  1987-05-04  |  5KB  |  116 lines

  1. (*----------------------------------------------------------------------*)
  2. (*             Send_Modem_Command --- Send command to modem             *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Send_Modem_Command( Modem_Text : AnyStr );
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Send_Modem_Command                                   *)
  10. (*                                                                      *)
  11. (*     Purpose:    Sends command to modem                               *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*         Send_Modem_Command( Modem_Text : AnyStr );                   *)
  16. (*                                                                      *)
  17. (*           Modem_Text --- text of command to send to modem            *)
  18. (*                                                                      *)
  19. (*     Calls:                                                           *)
  20. (*                                                                      *)
  21. (*        Async_Send                                                    *)
  22. (*        Async_Receive                                                 *)
  23. (*                                                                      *)
  24. (*     Remarks:                                                         *)
  25. (*                                                                      *)
  26. (*          If the string to be sent has not "Wait For" markers, then   *)
  27. (*          it is sent in its entirety in one call here.  If there ARE  *)
  28. (*          "Wait For" characters, then the flag WaitString_Mode is set *)
  29. (*          TRUE, Script_When_Text is set to the character to be found, *)
  30. (*          and  Script_When_Reply_Text is set to the remainder of the  *)
  31. (*          function key string.  This allows the terminal emulation to *)
  32. (*          properly process any received characters while PibTerm is   *)
  33. (*          waiting for the selected string to appear.                  *)
  34. (*                                                                      *)
  35. (*----------------------------------------------------------------------*)
  36.  
  37.  
  38. VAR
  39.    I:       INTEGER;
  40.    L:       INTEGER;
  41.    Ch:      CHAR;
  42.    MO_Char: CHAR;
  43.    Done:    BOOLEAN;
  44.  
  45. BEGIN (* Send_Modem_Command *)
  46.  
  47.    L      := LENGTH( Modem_Text );
  48.    I      := 1;
  49.    Done   := FALSE;
  50.  
  51.    WHILE( I <= L ) AND ( NOT Done ) DO
  52.       BEGIN
  53.  
  54.          MO_Char := Modem_Text[I];
  55.  
  56.          IF MO_Char = FK_CR THEN
  57.             Async_Send( CHR( CR ) )
  58.  
  59.          ELSE IF MO_Char = FK_Delay THEN
  60.             DELAY( One_Second_Delay )
  61.  
  62.          ELSE IF MO_Char = FK_Wait_For THEN
  63.             BEGIN   (* Wait For *)
  64.  
  65.                I := SUCC( I );
  66.  
  67.                IF ( I <= L ) THEN
  68.                   BEGIN
  69.  
  70.                      WITH Script_Wait_List[1] DO
  71.                         BEGIN
  72.                            NEW( Wait_Text );
  73.                            Wait_Text^ := Modem_Text[I];
  74.                            NEW( Wait_Reply );
  75.                            I := SUCC( I );
  76.                            IF ( I <= L ) THEN
  77.                               Wait_Reply^ := COPY( Modem_Text, I, SUCC( L - I ) )
  78.                            ELSE
  79.                               Wait_Reply^[0] := #0;
  80.                            Script_Wait_Check_Length := 1;
  81.                         END;
  82.  
  83.                      Script_Wait_Count      := 1;
  84.                      WaitString_Mode        := TRUE;
  85.                      Really_Wait_String     := TRUE;
  86.                      Script_Wait_Time       := Script_Default_Wait_Time;
  87.                      IF ( Script_Wait_Time <= 0 ) THEN
  88.                         Script_Wait_Time := 60;
  89.                      Script_Wait_Failure    := 0;
  90.                      Done                   := TRUE;
  91.                      Script_Wait_Start      := TimeOfDay;
  92.  
  93.                   END;
  94.  
  95.             END
  96.          ELSE IF MO_Char = FK_Ctrl_Mark THEN
  97.             BEGIN
  98.                IF ( ( I + 2 ) <= L ) THEN
  99.                   IF ( Modem_Text[ SUCC( I ) ] = '''' ) THEN
  100.                      I := I + 2;
  101.                Async_Send( Modem_Text[I] );
  102.             END
  103.          ELSE
  104.             BEGIN
  105.                Async_Send( Modem_Text[I] );
  106.                IF ( Modem_Command_Delay > 0 )
  107.                   THEN DELAY( Modem_Command_Delay );
  108.             END;
  109.  
  110.          I := SUCC( I );
  111.  
  112.       END;
  113.  
  114. END   (* Send_Modem_Command *);
  115.  
  116.